package com.gxa.community.admin.controller.bill;

import com.gxa.community.admin.service.bill.BillCommissionService;
import com.gxa.community.core.pojo.dto.bill.BillCommissionDto;
import com.gxa.community.core.pojo.dto.bill.storage.BillCommissionStorageDto;
import com.gxa.community.core.utils.R;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 作者： Juran on 2022-07-20 9:01
 * 作者博客：iit.la
 */
@RestController
@RequestMapping("/bill/commission")
@Log4j2
@Validated
public class BillCommissionController {
    //TODO 数据校验

    @Autowired
    BillCommissionService billCommissionService;

    @PostMapping("addCommissionInfo")
    public R addCommissionInfo(@RequestBody BillCommissionStorageDto billCommissionStorageDto){
        return billCommissionService.addCommissionInfo(billCommissionStorageDto);
    }

    @PostMapping("queryCommissionInfo")
    public R queryUserCommissionInfo(@RequestBody BillCommissionDto billCommissionDto,
                                     long page,
                                     long size) {

        return billCommissionService.queryUserCommissionInfo(billCommissionDto,
                ObjectUtils.isEmpty(page) ? 1 : page,
                ObjectUtils.isEmpty(page) ? 5 : size);
    }
}
